package com.atguigu.yygh.sms.controller;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.sms.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mgx
 * @version 1.0
 * @description: TODO
 * @date 2022/9/1 15:11
 */
@RestController
@RequestMapping("/user/sms")
@Api(tags = {"验证码服务管理"})
public class SmsController {

    @Autowired
    private SmsService smsService;

    @ApiOperation(value = "发送验证码")
    @PostMapping("/send/{phone}")
    public R sendCode(@PathVariable("phone") String phone) {
        boolean flag = smsService.sendCode(phone);
        if(flag) {
            return R.ok();
        }else {
            return R.error();
        }
    }
}
